export const setToken = (props) => {
    localStorage.setItem('vueTwoToken', JSON.stringify(props));
}

export const getToken = () => {
    return JSON.parse(localStorage.getItem('vueTwoToken')) ? JSON.parse(localStorage.getItem('vueTwoToken')) : {
        token: ''
    };
}

/**
 * @description 使用递归处理路由菜单，生成一维数组
 * @param {Array} routerList 所有菜单列表
 * @param {Array} newArr 菜单的一维数组
 * @return array
 */
export function handleRouter(routerList, newArr=[]) {
    routerList.forEach((item) => {
        typeof item === "object" && item.path && item.path !== '/' && newArr.push(item.path);
        item.children && item.children.length && handleRouter(item.children, newArr);
    });
    return newArr;
}